/*
 * Example_02.cpp
 */

#include <iostream>
using namespace std;

class BaseEx {
public:
	BaseEx() {
		cout << "BaseEx ctor" << endl;
	}
	virtual const char* name() {
		return "BaseEx";
	}
};

class DerivedEx : public BaseEx {
public:
	DerivedEx() {
		cout << "DerivedEx ctor" << endl;
	}
	const char* name() {
		return "DerivedEx";
	}
};

void exTest() {
	try {
		DerivedEx de;
//		DerivedEx* pde = &de;
		throw de;
	} catch( BaseEx &e ) {
		cout << "Caught BaseEx in exTest: name=" << e.name() << endl;
		throw;
	}
}

//int main() {
//	cout << "Example_02" << endl << "----------" << endl;
//	try {
//		exTest();
//	} catch( BaseEx &e ) {
//		cout << "Caught BaseEx in main: name=" << e.name() << endl;
//	} catch(...) {
//		cout << "Caught unknown" << endl;
//	}
//	return 0;
//}
